<?php
/**
 * 同步保单信息
 */
class Cli_UpdatenoController extends Ctrl_Cli{
	public function indexAction(){
		while(true){
			$tTime = time();
			$tRunlogdir = APPLICATION_PATH . '/shell/runlog/cli_updateno.run';
			Tool_Fnc::writefile($tRunlogdir,$tTime);
			$this->opt();
			sleep(5);
		}
		exit;
	}
	private function opt(){
		$tHCTIMO = new Huadao_Core_T_InsuredModel;
		$tUMO = new UserModel;
		$tUDatas = $tUMO->field('critcode')->fList();
		foreach($tUDatas as $k=>$v){
			$tURow = $tHCTIMO->field('CRITCODE,INSUREDNO')->where('CRITCODE = "'.$v['critcode'].'"')->fRow();
			if(!empty($tURow)){
				$tSql = 'update '.$tUMO->table.' set insuredno = "'.$tURow['INSUREDNO'].'" where critcode = "'.$tURow['CRITCODE'].'"';
				$tUMO->exec($tSql);
			}
		}
		Tool_Fnc::ajaxMsg('操作成功',1);
	}
}
?>
